
<template>
<div>

  <el-row type="flex" class="row-bg">

 
  <el-col :span="10" :offset="1">
 
    <el-button  type="primary" style="margin-left:50px;" @click="additem" >添加</el-button>
  </el-col>

  </el-row>
  
 <div class="space20">
 </div>


 
  
   <el-form :model="item"  label-width="140px" ref="item"  :inline="true" class="demo-ruleForm"  :key="item.IP_ITEM_ID"  v-for="(item,index) in producename">

       <el-form-item label="单项自付额内"
    :prop="'IP_ITEM_ZFEN'"
    :rules="{
      required: true, message: '单项自付额内', trigger: 'blur'
    }"
  >
    <el-input v-model="item.IP_ITEM_ZFEN"></el-input>
  </el-form-item>
  <el-form-item label="单项自付额外"
    :prop="'IP_ITEM_ZFEW'"
    :rules="{
      required: true, message: '单项自付额外不能为空', trigger: 'blur'
    }"
  >
    <el-input v-model="item.IP_ITEM_ZFEW"></el-input>
  </el-form-item>  
  <el-form-item label="单项给付比例内"
    :prop="'IP_ITEM_ZFBLN'"
    :rules="{
      required: true, message: '单项给付比例内不能为空', trigger: 'blur'
    }"
  >
    <el-input v-model="item.IP_ITEM_ZFBLN"></el-input>
  </el-form-item>
   <el-form-item label="单项给付比例外"
    :prop="'IP_ITEM_ZFBLW'"
    :rules="{
      required: true, message: '单项给付比例外不能为空', trigger: 'blur'
    }"
  >
    <el-input v-model="item.IP_ITEM_ZFBLW"></el-input>
  </el-form-item>
 
   <el-form-item label="给付限额内"
    :prop="'IP_ITEM_MAXM'"
    :rules="{
      required: true, message: '给付限额内不能为空', trigger: 'blur'
    }"
  >
    <el-input v-model="item.IP_ITEM_MAXM"></el-input>
  </el-form-item>
   <el-form-item label="给付限额外"
  
  >
    <el-input v-model="item.IP_ITEM_MAXMW"></el-input>
  </el-form-item>
  </el-form-item>
    <el-form-item label="是否是每日"
   :prop="'IP_ITEM_ISPER'"
    :rules="{
      required: true, message: '是否是每日不能为空', trigger: 'blur'
    }"
  >
     <el-radio-group v-model="item.IP_ITEM_ISPER" >
      <el-radio label="是"></el-radio>
      <el-radio label="否"></el-radio>
    </el-radio-group> 
  </el-form-item>
    <el-form-item label="给付期限"
   :prop="'IP_ITEM_MAXDAY'"
   
   
  >
    <el-input v-model="item.IP_ITEM_MAXDAY"></el-input>
  </el-form-item>    
     <el-form-item label="保险责任项"
   :prop="'DUTYITEM_ID'"
    :rules="{
      required: true, message: '保险责任项不能为空', trigger: 'blur'
    }"
  >
    <el-select v-model="item.DUTYITEM_ID" placeholder="请选择">
    <el-option
      v-for="item in dutyname"
      :key="item.DUTYITEM_ID"
      :label="item.DUTYITEM_NAME"
      :value="item.DUTYITEM_ID"
      >
    </el-option>
  </el-select>
  </el-form-item>   
      <el-button style="float: right; margin-right:50px;" type="danger" @click="delectitem(item)" >删除</el-button>
 
   </el-form>
 
 

</div>
</template>
<script>
    import {
        mapState
    } from 'vuex';
    import liepeiup_item from '@/components/liepei/liepeiup_item';
    import getid from '@/js/getid';
    export default {
        props: {
            index: {
                type: Number,
                default: 0
            },
             id: {
                type: String,
                default: 0
            },
            
        },
        data() {
            return {
                 producename:[],
                 dutyname:[]

            };
        },
        computed: mapState({
               produce: state => state.produce.produce
        }),
        methods: {    
            additem() { 
                    this.producename.push({
                        IP_ITEM_ID: getid.getid(),
                        IP_ITEM_ZFBLN: "",
                        IP_ITEM_ZFBLW:"",
                        IP_ITEM_ZFEN:"",
                        IP_ITEM_ZFEW:"",
                        IP_ITEM_MAXM:"",
                        IP_ITEM_ISPER:"",
                        IP_ITEM_MAXDAY:"",
                        DUTYITEM_ID:"",
                    });                    
            }, 
            delectitem(item){
               var index = this.producename.indexOf(item)
                if (index !== -1) {
                    this.producename.splice(index, 1)
                }
            } 
        },
        created() {    
          this.producename= this.produce[this.index].IP_ITEM;
            this.$http.get("DutyItem/1?fid="+this.id).then(response => {
                var data = response.body;
            
                this.dutyname = data;
            }, response => {
                this.$notify.error({
                    title: '网络错误',
                    message: '网络错误'
                });
                this.loding = false;
            });
        }

    }
</script>